//
//  MainViewController.m
//  BeautifulLockerRoom
//
//  Created by mac on 16/7/27.
//  Copyright © 2016年 Winny. All rights reserved.
//

#import "MainViewController.h"
#import "Masonry.h"
#import "TopNavagation.h"
#import "ContentScrollView.h"
#import "menuScrollView.h"
#import "SmallScrollView.h"



@interface MainViewController ()
{
    UIButton * _btn;
    NSInteger _tagInfo;
}
/**菜单栏*/
@property (nonatomic,strong)menuScrollView * menuSV;

/**内容栏*/
@property (nonatomic,strong)ContentScrollView * contentSV;

/**顶部搜索栏显示的文字*/
@property (nonatomic,strong)TopNavagation * topNavagation;

/**菜单旁的箭头按钮*/
@property (nonatomic,strong)UIButton * arrowButton;

/***/
@property (nonatomic,strong)NSTimer * timer;

@end

@implementation MainViewController
-(TopNavagation *)topNavagation
{
    if (!_topNavagation) {
        
        _topNavagation = [[TopNavagation alloc]init];
    }
    return _topNavagation;
}
-(menuScrollView *)menuSV
{
    if (!_menuSV) {
        _menuSV = [[menuScrollView alloc]initWithUrl:MAINMENUURL];
    }
    return _menuSV;
}
-(UIButton *)arrowButton
{
    if (!_arrowButton) {
        _arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _arrowButton.frame = CGRectMake(WINDOWWIDTH - 40, 64, 40, 40);
        _arrowButton.backgroundColor = [UIColor whiteColor];
        [_arrowButton setImage:[UIImage imageNamed:@"button_home_page_moredown1"] forState:UIControlStateNormal];
        [_arrowButton addTarget:self action:@selector(buttonClick1:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _arrowButton;
}
-(ContentScrollView *)contentSV
{
    if (!_contentSV)
    {
        _contentSV = [[ContentScrollView alloc]init];
    }
    return _contentSV;
}
#pragma mark - viewDidLoad
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.view.backgroundColor = [UIColor colorWithRed:242.0/255 green:242.0/255 blue:242.0/255 alpha:1];
    
    [self.view addSubview:self.menuSV];
    [self.view addSubview:self.arrowButton];
    [self.view addSubview:self.contentSV];
    [self.view addSubview:self.topNavagation];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(reciveNotice:) name:@"notice" object:nil];
    
}

- (void)reciveNotice:(NSNotification *)notification{
    
    NSInteger tag = [[notification.userInfo objectForKey:@"tag"]integerValue];
    
    if (tag!=_tagInfo)
    {
        _tagInfo = tag;
        self.contentSV.contentOffset = CGPointMake(tag * WINDOWWIDTH, 0);
    }
}

-(void)buttonClick1:(UIButton *)sender
{
    
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"test" object:nil];
}
@end
